#!/usr/bin/env python
# -*- coding: utf-8 -*- 
############################################################################
#    Copyright (C) 2007-2008
#                  Ferraro Luciano (aka lux) <luciano.ferraro@gmail.com>
#                  Matto Scacco (aka checkm, scaccom) <matto.scacco@gmail.com>
#
#
#    This program is free software; you can redistribute it and/or modify 
#    it under the terms of the GNU General Public License as published by 
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the
#    Free Software Foundation, Inc.,
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
############################################################################

import gtk

menubar_xml = \
"""
<ui>
    <menubar name='MenuBar'>
        <menu action='FileMenu'>
            <menuitem action='Connect'/>
            <separator/>
            <menuitem action='Quit'/>
        </menu>
        <menu action='HelpMenu'>
            <menuitem action='About'/>
        </menu>
    </menubar>
</ui>
"""

class MenuBar (gtk.UIManager):
    def __init__ (self):
        gtk.UIManager.__init__ (self)
        
        actions = self.build_actions()
        
        self.insert_action_group(actions, 0)
        self.add_ui_from_string(menubar_xml)
        #self.add_accel_group(ui.get_accel_group())
    
    def build_actions (self):
        entries = (
                  ( "FileMenu", None, "_Merdim" ),
                  ( "HelpMenu", None, "_Help" ),
                  
                  ( "Connect", gtk.STOCK_CONNECT, "_Connect", "<control>N", "Connect to a server", None ),
                  ( "Quit", gtk.STOCK_QUIT, "_Quit", "<control>Q", "Quit client", None ),
                  ( "About", gtk.STOCK_ABOUT, "_About", "<control>A", "About client", None ),
                  )
        
        actions = gtk.ActionGroup("Actions")
        actions.add_actions(entries)
        
        return actions
